package com.jc.wx.utils;

import java.security.SecureRandom;
import java.util.Random;

/**
 * @Description: 生成随机四位验证码工具类
 * @Author: ASL_ly
 * @Package: com.jc.wx.utils
 * @Project: jc-club
 * @Date: 2024/10/29  22:59
 */
public class VerCodeGenerateUtil {

    private static final String SYMBOLS = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
    private static final Random RANDOM = new SecureRandom();
    /**
     * 生成4位随机验证码
     * @return 返回4位验证码
     */
    public static String getVerCode() {
        char[] nonceChars = new char[5];
        for (int index = 0; index < nonceChars.length; ++index) {
            nonceChars[index] = SYMBOLS.charAt(RANDOM.nextInt(SYMBOLS.length()));
        }
        return new String(nonceChars);
    }
}
